﻿using System;
using System.Collections;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;

namespace Jy123.Web.Friend
{
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class FriendClassAdd : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            int userID;
            string strUserIdFromCookie = Common.Cookie.getCookie("UserID");
            if (string.IsNullOrEmpty(strUserIdFromCookie))
            {
                context.Response.Redirect("/");
            }
            userID = int.Parse(strUserIdFromCookie);
            string cName = context.Request["cName"];
            string msg = string.Empty;
            if (!string.IsNullOrEmpty(cName))
            {
                Jy123.Model.User_FriendClass mFriendClass = new Jy123.Model.User_FriendClass();
                Jy123.BLL.User_FriendClass bllFriendClass = new Jy123.BLL.User_FriendClass();
                mFriendClass.FUser = userID;
                mFriendClass.CName = cName;
                int effectRows = bllFriendClass.Add(mFriendClass);
                if (effectRows > 0)
                {
                    msg = "添加分组成功!,ok";
                }
                else
                {
                    msg = "添加分组失败!,error";
                }
                ////msg = "<script>$(function(){$.moonbox.ok('保存相册成功!');})</script>";                
                //context.Response.ContentType = "text/plain"; 
                ////context.Response.Write("<script>$(function(){fillhtml('dpro', '/Friend/FriendClassList.ashx');})</script>");
                //context.Response.Write(msg);
            }
            else
            {
                msg = "输入不可为空!,warning";
            }
            context.Response.ContentType = "text/plain";
            context.Response.Write(msg);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
